using UnityEngine;

public class PlayerState
{
    protected PlayerStateMachine StateMachine;
    protected Player player;
    protected SkillManager skillManager;
    protected Rigidbody2D rb;
    protected int xInput;
    protected float yInput;
    private string animBoolName;
    protected float stateTimer;
    protected bool triggerCalled;

    public PlayerState(Player player, string animBoolName)
    {
        this.player = player;
        skillManager = player.SkillManager;
        rb = player.Rb;
        StateMachine = player.StateMachine;
        this.animBoolName = animBoolName;
    }

    public virtual void Enter()
    {
        player.Anim.SetBool(animBoolName, true);
        triggerCalled = false;
    }

    public virtual void Exit()
    {
        player.Anim.SetBool(animBoolName, false);
    }

    public virtual void Update()
    {
        stateTimer -= Time.deltaTime;
        if (Input.GetAxisRaw("Horizontal") > 0)
            xInput = 1;
        else if (Input.GetAxisRaw("Horizontal") < 0)
            xInput = -1;
        else if (Input.GetAxisRaw("Horizontal") == 0)
            xInput = 0;
        // xInput = Input.GetAxisRaw("Horizontal");
        yInput = Input.GetAxisRaw("Vertical");
        player.Anim.SetFloat("yVelocity", rb.velocity.y);
    }

    public virtual void AnimationFinishedTrigger()
    {
        triggerCalled = true;
    }
}